<%@ page import="com.edu.bean.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%

    User loginUser = (User) session.getAttribute("loginUser");
    if (loginUser == null) {
        response.sendRedirect("login.jsp");
    }
%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div>
    <form action="../book/blurryAllBook" method="get">
        <input type="text" name="blurryName" value="${param.blurryName}">
        <input type="submit" value="查询">
    </form>
    <br>
    <form action="../book/addBook" method="post">
        <input type="hidden" name="_method" value="POST">
        <input type="text" name="bookName" placeholder="请输入书名">
        <input type="text" name="bookNum" placeholder="请输入数量">
        <input type="submit" value="添加">
    </form>
</div>
<table border="1">
    <tr>
        <td>书名</td>
        <td>数量</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${allBook}" var="book" varStatus="status">
        <tr>
            <td>${book.bookName}</td>
            <td>${book.bookNum}</td>
            <td>
                <form action="../book/removeBook?bookId=${book.bookId}" method="post">
                    <input type="hidden" name="_method" value="DELETE">
                    <input type="submit" value="删除">
                </form>
            </td>
            <td>
                <a href="../book/detailBook?bookId=${book.bookId}">查看明细</a>
            </td>
        </tr>
    </c:forEach>
</table>
<div>
    <a href="../book/firstPage">首页</a>
    <c:if test="${bookPageInfo.isHasPreviousPage()}">
        <a href="../book/toPage?pageNum=${bookPageInfo.pageNum-1}">上一页</a>
    </c:if>
    <c:forEach var="book" varStatus="status" begin="1" end="${bookPageInfo.getPages()}">
        <a href="../book/toPage?pageNum=${status.index}">${status.index}</a>
    </c:forEach>
    <c:if test="${bookPageInfo.isHasNextPage()}">
        <a href="../book/toPage?pageNum=${bookPageInfo.pageNum+1}">下一页</a>
    </c:if>
    <a href="../book/lastPage">尾页</a>
</div>

</body>
</html>
